<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :imgList="swiper"></home-swiper>
    <icons :dataList="icons"></icons>
    <list :dataList="list"></list>
  </div>
</template>

<script>
import HomeHeader from '@/pages/home/components/Header'
import HomeSwiper from './components/Swiper.vue'
import 'swiper/dist/css/swiper.css'
import Icons from '@/pages/home/components/Icons.vue'
import List from './components/List.vue'
import axios from 'axios'

export default {
  components: {
    List,
    HomeSwiper,
    HomeHeader,
    Icons},
  name: 'Home',
  data: function () {
    return {
      swiper: [],
      icons: [],
      list: [],
      city: ''
    }
  },
  methods: {
    getData: function () {
      axios.get('/api/home.json').then(this.handleAjax)
    },
    handleAjax: function (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        console.log(data)
        this.swiper = data.swiper
        this.icons = data.icons
        this.list = data.list
        this.city = data.city
      }
    }
  },
  mounted: function () {
    this.getData()
  }
}
</script>

<style>

</style>
